/*
 * 7JUL2010_array_a.c
 *
 *  Created on: Jun 19, 2012
 *      Author: ubuntu
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int mystrcspn(char *s1, char *s2) {

	int i = 0;

	int lengths1 = strlen(s1);
	int max = lengths1;

	//printf("%d %d", lengths1, max);

	for (i = 0; i < lengths1; i++) {
		int j = 0;
		int lengths2 = strlen(s2);
		for (j = 0; j < lengths2; j++) {

			if (i < max && s1[i] == s2[j]) {
				max = i;
				break;
			}
		}
	}
	return max;
}

int main(int argc, char **argv) {

	printf("pré-definida: %d\n", strcspn(argv[1], argv[2]));
	printf("mystrcpn: %d\n", mystrcspn(argv[1], argv[2]));

}

